<script>
    function fn(num) {
        let j = 0;
        for (let i = 0; i < num.length; i++) {
            if (num[i] != 0) {
                num[j] = num[i]
                j++
            }
        }
        for (let i = j; i < num.length; i++) {
            num[i] = 0
        }
        return num
    }
    console.log(fn([1, 2, 0, 1, 2, 0, 3, 3]));
    
</script>